//
//  TTPayRecordCell.m
//  TaoTuo
//
//  Created by admin on 2019/12/16.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTPayRecordCell.h"

@interface TTPayRecordCell ()

@property (weak, nonatomic) IBOutlet UIView *topLineView;
@property (weak, nonatomic) IBOutlet UIView *bottomLineView;
@property (weak, nonatomic) IBOutlet UIImageView *midImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UIButton *payButton;


@end

@implementation TTPayRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor whiteColor];
    self.payButton.layer.cornerRadius = 10;
    self.payButton.layer.borderWidth = 0.5;
    self.payButton.layer.borderColor = kMainColor.CGColor;
    
    self.midImageView.layer.cornerRadius = 5;
    self.midImageView.layer.masksToBounds = YES;
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.separatorInset = UIEdgeInsetsMake(0, 0, 0, 600);
}

- (void)setModel:(TTPayRecordCellModel *)model
{
    _model = model;
    self.titleLabel.text = model.payTypeName;
    
    if (model.isGoToPay && model.orderStatus < 80) {
        self.payButton.hidden = NO;
    } else {
        self.payButton.hidden = YES;
    }
    
    if (![model.payTypeName isEqualToString:@"完成"] && model.stepState == 1) {
        self.contentLabel.text = [NSString stringWithFormat:@"%@%@￥%@", model.payDate, model.payMethod, model.payMoney];
    } else {
        self.contentLabel.text = @"";
    }
    
    if (model.stepState == 0) {
        self.midImageView.backgroundColor = kSeparatorColor;
        self.midImageView.image = [UIImage new];
    } else if (model.stepState == 1) {
        self.midImageView.image = [UIImage imageNamed:@"address_sel"];
    } else {
        self.midImageView.backgroundColor = kMainColor;
        self.midImageView.image = [UIImage new];
    }
    
    self.topLineView.hidden = model.hiddenTopLine;
    self.bottomLineView.hidden = model.hiddenBottomLine;
    
}


- (IBAction)payButtonClick:(UIButton *)sender {
    
    // 去支付页面
    if ([self.delegate respondsToSelector:@selector(payRecordViewCellToPay:)]) {
        [self.delegate payRecordViewCellToPay:self.model];
    }
    
}

@end
